<script type="text/javascript">

var tzBrowserSupported = true;
if( navigator.userAgent.toLowerCase().indexOf('chrome') > -1 )
{
	var chrmePosition = navigator.userAgent.toLowerCase().indexOf("chrome") + 7;
	var chrmVersionArr = navigator.userAgent.toLowerCase().substring(chrmePosition,navigator.userAgent.length-1).split(".");
	var chromeVrsn = 0;
	if( typeof chrmVersionArr[0] !== 'undefined')
	{
		chromeVrsn = Math.floor(parseInt(chrmVersionArr[0]));
		if( parseInt(chromeVrsn) < parseInt("20") )
		{
			tzBrowserSupported = false;
		}
	}
}
else if( navigator.userAgent.toLowerCase().indexOf('trident') > -1 )
{
	var ieVrsn = 0;
	ieVrsn = Math.floor(parseInt(jQuery.browser.version));
	if( parseInt(ieVrsn) < parseInt("11") )
	{
		tzBrowserSupported = false;
	}
}
else if( navigator.userAgent.toLowerCase().indexOf('firefox') > -1 )
{
	var firefoxVrsn = 0;
	firefoxVrsn = Math.floor(parseInt(jQuery.browser.version));
	if( parseInt(firefoxVrsn) < parseInt("11") )
	{
		tzBrowserSupported = false;
	}
}
else
{
	tzBrowserSupported = false;
}

if( ! tzBrowserSupported )
{
	window.location = BASE_URL + "/browser-display";
}

</script>
<?
//unset($_SESSION['sLoginFValue']);
//unset($_SESSION['sLoginGValue']); exit;
 global $facebook_login;
	global $google_login;
	global $facebookAppId;
	if(!isset($_SESSION['usersinfo'])){
	if(!isset($_SESSION['logoutStatus'])){
		$_SESSION['logoutStatus']=0;
		$value=0;
	}else if(isset($_SESSION['logoutStatus']) && $_SESSION['logoutStatus']==1){
		unset($_SESSION['logoutStatus']);
		$value=1;
	}else if(isset($_SESSION['logoutStatus']) && $_SESSION['logoutStatus']==0){
		$value=0;
	}
	
	if($value==0){
?>
<script type="text/javascript">
function show_login_status(network, status)
{
	if (status)
	{
		if( $('#tpName').html() != ""  )
		{
			$('#socialLoginSecond').val( network );
			return false;
		}
		if(network=='Facebook'){
			var fbpromptfired = getTpCookie("fbpromptfired");
			if( fbpromptfired != null && fbpromptfired != "" )
			{
				checkSecondTp();
				return false;
			}
			$('#tpName').html( 'Facebook' );
			$('#popUpConfirmTpLogin').popUpWindow({action: "open"});
			document.cookie="fbpromptfired=yes";
		}else if(network=='Google'){
			var googlepromptfired = getTpCookie("googlepromptfired");
			if( googlepromptfired != null && googlepromptfired != "" )
			{
				return false;
			}
			else
			{
				console.log( googlepromptfired );
			}
			$('#tpName').html( 'Google' );
			$('#popUpConfirmTpLogin').popUpWindow({action: "open"});
			document.cookie="googlepromptfired=yes";
		}
	}
}
</script>
<script>
window.fbAsyncInit = function(){
	FB.init({ appId:'<?echo $facebookAppId;?>', status:true,  cookie:true, xfbml:true});
	FB.getLoginStatus(function(response){
		if (response.status != "unknown")
		{
			show_login_status("Facebook", true);
		}else{
			//show_login_status("Facebook", false);
			checkGoogleLogin(2);
		}
	});
};
// Load the SDK Asynchronously
(function(d){
	var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
	js = d.createElement('script'); js.id = id; js.async = true;
	js.src = "//connect.facebook.net/en_US/all.js";
	d.getElementsByTagName('head')[0].appendChild(js);
}(document));

function checkGoogleLogin(valGoogle){
	if(valGoogle==2){
		$('#checkGoogleLogin1').val(valGoogle);
		var googleValue=$('#checkGoogleLogin').val();
		if(googleValue==1){
			show_login_status( 'Google',true );
		}
	}else{
		$('#checkGoogleLogin').val(valGoogle);
		if(valGoogle==1){
			$('#socialLoginSecond').val( 'Google' );
		}
	}
}
</script>
<img style="display:none;"
onload="checkGoogleLogin(1)"
onerror="checkGoogleLogin(0)"
src="https://accounts.google.com/CheckCookie?continue=https%3A%2F%2Fwww.google.com%2Fintl%2Fen%2Fimages%2Flogos%2Faccounts_logo.png&followup=https%3A%2F%2Fwww.google.com%2Fintl%2Fen%2Fimages%2Flogos%2Faccounts_logo.png&chtml=LoginDoneHtml&checkedDomains=youtube&checkConnection=youtube%3A291%3A1"
/>
<div id="fb-root"></div>
<?}}?>

<body style="overflow:hidden">
<?php
		global $homePageYes;
		$homePageYes="Yes";

		$baseUrl = $this->baseUrl;
		$basePath = $this->basePath;
?>

<script type="text/javascript" src="<?php echo $basePath; ?>/js/project/index.js"></script>
<script type="text/javascript" src="<?php echo $basePath; ?>/js/project/login-ready.js"></script>

<input type="hidden" id="loggedInStatus" <?php if( isset($_SESSION['usersinfo']) ) {?>value="loggedIn"<?php } ?> />
<input type="hidden" id="postClicked" value="0" />
<input type="hidden" id="nsfwMcClicked" value="0" />

<input type="hidden" id="socialLoginSecond" value="" />
<input type="hidden" id="homePageSection" value="1" />
<input type="hidden" id="checkGoogleLogin" />
<input type="hidden" id="checkGoogleLogin1" value="0" />


<?php if( ! isset($_SESSION['usersinfo']) ) {?>
<div class="main_container_search_block">
  <div class="container_search_block">
    <div class="search_title_box">Search</div>
    <div class="search_box_block input_container">
     <input type="text" id="searchTermHolder" class="search_box_props" placeholder="For Example #myname" style="font-size:0.7em" />
    </div>
    <div class="block_search_n_menu">
      <div class="go_search_btn" id="searchButtonDiv"><a href="Javascript:void(0);" id="homeSearchLink"><img src="<?php echo $basePath; ?>/images/go_search_btn.png" width="30" height="30" /></a></div>
  </div>
  </div>
</div>
<?php } ?>

<input type="hidden" id="highlightBoxesPerPage" value="5" />
<input type="hidden" id="highlightBoxesOffset" value="0" />
<input type="hidden" id="publicBoxesPerPage" value="10" />
<input type="hidden" id="publicBoxesOffset" value="0" />
<input type="hidden" id="montageBoxesPerPage" value="10" />
<input type="hidden" id="montageBoxesOffset" value="0" />
<input type="hidden" id="publicBoxesOn" value="1" />
<input type="hidden" id="montageBoxesOn" value="1" />
<input type="hidden" id="homepageSearched" value="0" />
<input type="hidden" id="pboxesOnBeforeSearch" value="0" />

<div class="body_main_container">
	<div class="body_middle_container<?php if( isset($_SESSION['usersinfo']) ) {?> body_mar_b<?php } ?>">
		<?php if( isset($_SESSION['usersinfo']) ) {?>
			<div class="home_search input_container1">
				<span>Search</span>&nbsp;<div style="float:right;margin-right:-3px;"><input type="text" id="searchTermHolder" class="home_searc_1" placeholder="For Example #myname" style="font-size:0.7em" />
				<input  type="text" class="home_searc_2" id="pvtUniqueCodeHolder" placeholder="To access Private Please Specify Unique code for example #u7873dg" style="font-size:0.7em"/><a href="Javascript:void(0);" id="homeSearchLink"><img src="<?php echo $basePath; ?>/images/go_search_btn.png" width="30" height="30" /></a></div>
				<div class="clearfix"></div>
			</div>
		<?php } ?>
		<div class="content_home_highlights">
			<div class="heading_highlights">
			<div class="heading_title_highlights">Highlights & Current affairs</div>
			<div class="wrap_text_links"><a href="Javascript:void(0);" id="postHighliths" class="link__post_n_vote">Post</a>&nbsp;|&nbsp;<a href="<?php echo $baseUrl; ?>/databox/enlist-highlights" class="link__post_n_vote<?php if( isset($_SESSION['usersinfo']) && isset($_SESSION['usersinfo']->hinting_state) && $_SESSION['usersinfo']->hinting_state == 1 ) {?> tooltip<?php } ?>">Vote
			<?php if( isset($_SESSION['usersinfo']) && isset($_SESSION['usersinfo']->hinting_state) && $_SESSION['usersinfo']->hinting_state == 1 ){?>
				<span>
				<div class="callout"></div>
				<strong>Vote Information</strong>
				<br>This is the easy-to-use Tooltip driven purely by CSS.This is the easy-to-use Tooltip driven purely by CSS.This is the easy-to-use
				</span>
			<?php } ?>
			</a></div>
			</div>
			<ul id="list_highlights"><?php if( isset($this->homehighlightBoxesArray) )
					{foreach( $this->homehighlightBoxesArray as $key=>$currentBoxData ){
						$viewUrl = "";
						if( isset($_SESSION['usersinfo']) )
						{
							if($currentBoxData['settingId']==3){
								$viewUrl = "post-vertical";
							}else{
								$viewUrl = "post-horizontal";
							}
						}
						else
						{
							if($currentBoxData['settingId']==3){
								$viewUrl = "pre-vertical";
							}else{
								$viewUrl = "pre-horizontal";
							}
						}
						$displayCustomizationUrl = $baseUrl;
						$catTitles = str_replace( "-","~",$currentBoxData["category_title"] );
						$catTitle = str_replace( " ","-",$catTitles );
						$catHashName = substr( $currentBoxData["user_hashname"],1 );
						$catImageUrl=explode(".",$currentBoxData["category_image"]);
						$catImageUrll=$catImageUrl[0];
						$displayCustomizationUrl .= "/databox/" . $viewUrl . "/" . $currentBoxData["category_id"] . "+" . $catImageUrll . "+" . $catHashName . "+" . $catTitle;?><li>
								<div class="highlight_block home_pos_r">
								<div class="image_highlight"><a href="<?php echo $displayCustomizationUrl; ?>" onClick='Javascript:displayCustomization(<?php echo $currentBoxData["category_id"]; ?>,"<?php echo $currentBoxData["user_hashname"]; ?>","<?php echo $currentBoxData["category_title"]; ?>",<? echo $currentBoxData['settingId']?>,"<? echo $catImageUrll?>");'><img alt="<?php echo $currentBoxData["user_hashname"]; ?>" src="<?php echo $basePath.'/images/project/categoryImages/'.$currentBoxData["category_image"]; ?>" width="263" height="234" /></a></div>
								<div class="hashtag_highlights"><a class="home_anchor_black" href="<?php echo $displayCustomizationUrl; ?>"><?php echo $currentBoxData["user_hashname"]; ?></a></div>
								<!--<div class="block_down_details_highlights">
								<div class="sources_number_block" id="highlights_sources_number"><?php //echo $currentBoxData["categoryLinksCount"]; ?></div>
								<div class="highlights_listed_sources">Listed Sources</div>
								</div>-->
								<div class="heighlights_pos_abso_left_title">
									<p><a class="home_anchor_black" href="<?php echo $displayCustomizationUrl; ?>"><?php if(strlen($currentBoxData["category_title"])>57)
										{
											echo substr($currentBoxData["category_title"],0,57) . '...';
										}
										else
										{
										echo $currentBoxData["category_title"];
										}?></a></p>
								</div>
								<div class="heighlights_pos_abso_left">
									<p>>> Listed Sources >> </p>
								</div>
								<div class="heighlights_pos_abso_right">
									<p><?php echo $currentBoxData["categoryLinksCount"]; ?></p>
								</div>
								</div>
							</li><?php } } ?></ul>
		</div>
		<!-- All the Public databoxes flow from here -->
		<div class="container_main_cats_">
			<div id="loadingBoxesDiv" style="display:none;position:relative;top:370px;left:350px;width:50px;background-color:#ffffff;"><img src="<?php echo $basePath; ?>/images/social_media/24x24_pg-loader-1.gif" /></div>
			<div class="heading_public_boxes">
				<div class="home_title">&#9654;&nbsp;&nbsp;<a href="Javascript:void(0);" id="publicBoxesLink" <?php if( isset($_SESSION['usersinfo']) && isset($_SESSION['usersinfo']->hinting_state) && $_SESSION['usersinfo']->hinting_state == 1 ) {?> class="tooltip"<?php } ?>>Public Databoxes 
				<?php if( isset($_SESSION['usersinfo']) && isset($_SESSION['usersinfo']->hinting_state) && $_SESSION['usersinfo']->hinting_state == 1 ){?>
					<span>
						<div class="callout"></div>
						<strong>Most Light-weight Tooltip</strong>
						<br>This is the easy-to-use Tooltip driven purely by CSS.This is the easy-to-use Tooltip driven purely by CSS.This is the easy-to-use Tooltip driven purely by CSS.This is the easy-to-use Tooltip driven purely by CSS.This is the easy-to-use Tooltip driven purely by CSS.This is the easy-to-use Tooltip driven purely by CSS.
					</span>
				<?php } ?>
				</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="Javascript:void(0);" id="memCollectionsLink"  <?php if( isset($_SESSION['usersinfo']) && isset($_SESSION['usersinfo']->hinting_state) && $_SESSION['usersinfo']->hinting_state == 1 ) {?> class="tooltip"<?php } ?>>Members
				<?php if( isset($_SESSION['usersinfo']) && isset($_SESSION['usersinfo']->hinting_state) && $_SESSION['usersinfo']->hinting_state == 1 ){?>
					<span>
						<div class="callout"></div>
						<strong>Most Light-weight Tooltip</strong>
						<br>This is the easy-to-use Tooltip driven purely by CSS.This is the easy-to-use Tooltip driven purely by CSS.This is the easy-to-use
					</span>
				<?php } ?>
				</a></div>
			</div>
			<ul id="list_public_boxes"><?php
		if( isset($this->homePublicBoxesArray) )
		{
			foreach( $this->homePublicBoxesArray as $key=>$currentBoxData )
			{
				$showMcNsfwPopup = false;
				if( (! isset($_SESSION['usersinfo'])) && (($currentBoxData["mature_content"] == 1) || ($currentBoxData["not_safe_for_work"] == 1)) )
				{
					$showMcNsfwPopup = true;
				}
				
				$viewUrl = "";
				if( isset($_SESSION['usersinfo']) )
				{
					if($currentBoxData['settingId']==3){
						$viewUrl = "post-vertical";
					}else{
						$viewUrl = "post-horizontal";
					}
				}
				else
				{
					if($currentBoxData['settingId']==3){
						$viewUrl = "pre-vertical";
					}else{
						$viewUrl = "pre-horizontal";
					}
				}
				$displayCustomizationUrl = $baseUrl;
				$catTitles = str_replace( "-","~",$currentBoxData["category_title"] );
				$catTitle = str_replace( " ","-",$catTitles );
				$catHashName = substr( $currentBoxData["user_hashname"],1 );
				$catImageUrl=explode(".",$currentBoxData["category_image"]);
				$catImageUrll=$catImageUrl[0];
				$displayCustomizationUrl .= "/databox/" . $viewUrl . "/" . $currentBoxData["category_id"] . "+" . $catImageUrll . "+" . $catHashName . "+" . $catTitle;?><li>
			<div class="public_box_block home_pos_r">
					<div class="hashtag_main_public_boxes hashtag_pos_ab"><p><?php if( $showMcNsfwPopup ){ ?><a class="home_anchor_black" href="javascript:void(0)" onClick='Javascript:displayNsfwMc(<?php echo $currentBoxData["category_id"]; ?>,"<?php echo $currentBoxData["user_hashname"]?>","<?php echo $currentBoxData["category_title"]; ?>",<? echo $currentBoxData["settingId"]?>,"<? echo $catImageUrll?>");'><?php } else { ?><a class="home_anchor_black" href="<?php echo $displayCustomizationUrl; ?>"><?php } ?>
					<?php if(strlen($currentBoxData["user_hashname"])>25)
							{
								echo substr($currentBoxData["user_hashname"],0,25) . '...';
							}
							else
							{
							echo $currentBoxData["user_hashname"]; }?></a></p></div>
							<?php if( $showMcNsfwPopup ){  ?><div class="image_block_publick_databox"><a href="javascript:void(0)" onClick='Javascript:displayNsfwMc(<?php echo $currentBoxData["category_id"]; ?>,"<?php echo $currentBoxData["user_hashname"]?>","<?php echo $currentBoxData["category_title"]; ?>",<? echo $currentBoxData["settingId"]?>,"<? echo $catImageUrll?>");'><img src="<?php echo $basePath; ?>/images/social_media/mature_content.jpg" width="234" height="302" /></a></div>
					<?php } else { ?><div class="image_block_publick_databox"><a href="<?php echo $displayCustomizationUrl; ?>"><img alt="<?php echo $currentBoxData["user_hashname"]; ?>" src="<?php echo $basePath.'/images/project/categoryImages/'.$currentBoxData["category_image"]; ?>" width="234" height="302" /></a></div>
						<div class="home_pos_abso">
							<p><a class="home_anchor_black" href="<?php echo $displayCustomizationUrl; ?>"><?php if(strlen($currentBoxData["category_title"])>57)
								{
									echo substr($currentBoxData["category_title"],0,57) . '...';
								}
								else
								{
								echo $currentBoxData["category_title"];
								}?></a></p>
						</div>
						<div class="home_pos_abso_left">
							<p>>> Listed Sources >> </p>
						</div>
						<div class="home_pos_abso_right">
							<p><?php echo $currentBoxData["categoryLinksCount"]; ?></p>
						</div>
					<?php } ?>
					<!--<div class="titleblock_public_databox"><?php //echo $currentBoxData["category_title"]; ?></div>-->
					<!--<div class="source_details_holder_public_databox">
					<div class="number_of_sources_public_databox">
					<div id="public_databoxes_sources_number"><?php //echo $currentBoxData["categoryLinksCount"]; ?></div>
					<div class="public_databox_listed_sources">Listed Sources</div>
					</div>
					</div>-->
				</div>
					</li><?php } } ?></ul>
			<div id="publicBoxesLoadingDiv" style="position:relative;display:none;" >
				<div class="home_publicboxes_loading" >
					<center><img src="<?php echo $basePath; ?>/images/social_media/bx_loader.gif" /></center>
				</div>
			</div>
		</div>
		<div id="publicBoxesDiv" style="display:none;">
		</div>
		<div id="memCollectionBoxesDiv" style="display:none;">
	<?php
		if( isset($this->homeMontageBoxesArray) )
		{
			foreach( $this->homeMontageBoxesArray as $key=>$currentBoxData )
			{
				$viewUrl = "user-collection";
				$displayUserCollectionUrl = $baseUrl;
				$displayUserCollectionUrl .= "/" . $viewUrl . "/" . $currentBoxData["user_id"];?><li>
			<div class="public_box_block home_pos_r"><?php $montageHashName="";
						if( ! is_null($currentBoxData["montage_hash_name"]) && $currentBoxData["montage_hash_name"] != "" )
						{
							if(strlen($currentBoxData["montage_hash_name"])>25)
							{
								$montageHashName = substr($currentBoxData["montage_hash_name"],0,25) . '...';
							}
							else
							{
								$montageHashName = $currentBoxData["montage_hash_name"];
							}?><div class="hashtag_main_public_boxes hashtag_pos_ab"><p><a class="home_anchor_black" href="<?php echo $displayUserCollectionUrl; ?>">#<?php echo $montageHashName; ?></a></p></div><?php }
							$memberDisplayImage = $basePath.'/images/project/montageImages/'.$currentBoxData["montage_image"];
							if( ! is_null($currentBoxData["montage_main_image"]) && $currentBoxData["montage_main_image"] != "" )
							{
								$memberDisplayImage = $basePath.'/images/project/montageMainImage/'.$currentBoxData["montage_main_image"];
							}?><div class="image_block_publick_databox">
							<a href="<?php echo $displayUserCollectionUrl; ?>" onClick="Javascript:displayUserCollection(<?php echo $currentBoxData["user_id"]; ?>)" ><img src="<?php echo $memberDisplayImage; ?>" width="234" height="302" /></a></div><?php $montageTitle = "";
								if( ! is_null($currentBoxData["montage_title"]) && $currentBoxData["montage_title"] != "" )
								{
									if(strlen($currentBoxData["montage_title"])>57)
									{
										$montageTitle = substr($currentBoxData["montage_title"],0,57) . '...';
									}
									else
									{
										$montageTitle = $currentBoxData["montage_title"];
									}?><div class="home_pos_abso"><p><a class="home_anchor_black" href="<?php echo $displayUserCollectionUrl; ?>"><?php echo $montageTitle;?></a></p></div><?php } ?><div class="home_pos_abso_left">
							<p>>> Listed Sources >> </p>
						</div>
						<div class="home_pos_abso_right">
							<p><?php echo $currentBoxData["userWiseLinksCount"];?></p>
						</div><?php } ?></div>
					</li><?php } ?></div>
	</div>
</div>

<div id="popUpConfirmTpLogin" class="pop-up-display-content conform_popup_content">
	<p>Do you want to continue with your <b id="tpName"></b> login ?</p><br/>
	<p><a id="tpLoginLink" class="larg_btn" href="Javascript:void(0);">CONTINUE</a>
	&nbsp;&nbsp;<a id="tpNoLink" class="larg_btn" href="Javascript:void(0);">NO</a></p>
</div>

</body>
<link rel="stylesheet" href="<?php echo $basePath; ?>/auto/jquery-ui.css">
<input type="hidden" id="totalValue" name="totalValue" />
<script>
$(function() {
	$("#searchTermHolder").autocomplete({	
		source: function( request, response ) {
			var keywordsss = $('#searchTermHolder').val();
			var hashName='s';
			$.ajax({
				url: BASE_URL+'/search-hash-names',
				dataType: "json",
				type	: "POST",
				data	:{value:keywordsss},
				success: function( data ) {
					if(data.output!=0) {		
						response( $.map( data.searchHashNames, function( item ) {
							return {
								label: item.ref,
							}
						}));
					}else{
						$(".ui-autocomplete").css("display","none");
					}
				}				
			});
		},
		minLength: 0,	
		open: function(event, ui) {	
			$("ul").removeClass("ui-widget-content");		
			$(".ui-autocomplete").addClass("searchboxscroll2");
			if($("#loggedInStatus").val()=='loggedIn'){
				$(".ui-autocomplete").css("width","460px; !important");
			}else{
				$(".ui-autocomplete").css("width","876px !important");
			}			
		},
		select: function(event, ui) {
			$("#searchTermHolder").val(ui.item.label); 
			return false;
		},
		focus: function(event, ui) {
			return false;
		}			
	});
	$("#searchTermHolder").data( "autocomplete" )._renderItem = function( ul, item ) {
		var hashname=item.label;		
		 return $("<li><a data-value='"+item.label+"' onClick ='set_item(this.text);'>" + item.label + "</a></li>")
		 .data("item.autocomplete", item)            
		 .appendTo(ul);				
	};
});
$("#searchTermHolder").live("keydown",".ui-corner-all",function(e){
if (e.keyCode == 13) {
	   var hashValue=$("#searchTermHolder").val();
	   set_item(hashValue);
	}
});


$(document).ready(function() {

	$('#tpLoginLink').click(function(event)
	{
		$('#popUpConfirmTpLogin').popUpWindow({action: "close"});
		if( $('#tpName').html() == 'Facebook' )
		{
			openPopup('<?echo $facebook_login;?>');
		}
		else if( $('#tpName').html() =='Google' )
		{
			openPopup('<?echo $google_login;?>');
		}
	});
	$('#tpNoLink').click(function(event)
	{
		$('#popUpConfirmTpLogin').popUpWindow({action: "close"});
		checkSecondTp();
	});

    var nicesx = $(".ui-autocomplete,.searchboxscroll2").niceScroll({touchbehavior:false,cursorcolor:"#acacac",cursoropacitymax:0.6,cursorwidth:8});
    
  });
  //alert($('.container_main_cats_').height());
  $('.container_main_cats_').css('height',($(window).height()-140)+'px');
  $('.content_home_highlights').css('height',($(window).height()-140)+'px');
  $(window).on('resize', function() {
  $('.container_main_cats_').css('height',($(window).height()-140)+'px');
  $('.content_home_highlights').css('height',($(window).height()-140)+'px');
});
</script>